package pub.wkq.thread;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;

public class QuittableTasks {
    public static final int COUNT = 1500;

    public static void main(String[] args) {
        ExecutorService exec = Executors.newCachedThreadPool();
        List<QuittableTask> tasks = IntStream.range(1, COUNT).mapToObj(QuittableTask::new).peek(quittableTask -> exec.execute(quittableTask)).toList();
        new Nap(1);
        tasks.forEach(QuittableTask::quit);
//        exec.shutdown();
    }
}
